/*
 * Copyright (c) 2007 jNetX.
 * http://www.jnetx.com
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * jNetX. You shall not disclose such Confidential Information and
 * shall use it only in accordance with the terms of the license
 * agreement you entered into with jNetX.
 *
 * $Id$
 */
package com.jnetx.javax.sip.header;

import javax.sip.header.AllowHeader;
import java.text.ParseException;

/**
 * @author <a href="mailto:dparhonin@jnetx.ru">Dmitry Parhonin</a>
 * @version $Revision$
 */
public class AllowHeaderImpl extends HeaderBase implements AllowHeader {
    private String allowedMethod;

    private static final AllowHeaderParser parser = new AllowHeaderParser();

    public AllowHeaderImpl() {
        super(AllowHeader.NAME);
    }

    AllowHeaderImpl(byte[] data, int start, int end) {
        super(AllowHeader.NAME, data, start, end);
    }

    public Object clone() {
        final AllowHeaderImpl header = new AllowHeaderImpl();
        header.cloneBase(this);
        if (parsed) {
            header.allowedMethod = this.allowedMethod;
        }
        return header;
    }

    protected HeaderParser getParser() {
        return parser;
    }

    protected String getValueAsString() {
        return allowedMethod;
    }

    /**
     * Sets the Allow header value. The argument may be a single method name
     * (eg "ACK") or a comma delimited list of method names
     * (eg "ACK, CANCEL, INVITE").
     *
     * @param method - the String defining the method supported
     *               in this AllowHeader
     * @throws java.text.ParseException which signals that an error has been reached
     *                                  unexpectedly while parsing the method supported.
     */
    public void setMethod(String method) throws ParseException {
        this.allowedMethod = method;
    }

    /**
     * Gets the method of the AllowHeader. Returns null if no method is
     * defined in this Allow Header.
     *
     * @return the string identifing the method of AllowHeader.
     */
    public String getMethod() {
        return this.allowedMethod;
    }
}
/*
 * $Log$
 */